[TOOLS] Added option to xentrace to discard records in the buffer
authorGeorge Dunlap <gdunlap@xensource.com>
Tue, 27 Feb 2007 11:01:35 +0000 (06:01 -0500)
committerGeorge Dunlap <gdunlap@xensource.com>
Tue, 27 Feb 2007 11:01:35 +0000 (06:01 -0500)
before beginning the trace.

Signed-off-by: George Dunlap <gdunlap@xensource.com>
tools/xentrace/xentrace.c

index d37d86d8b6b5e005b6c81e3d1e8a2073890bbabe..d0cea17c2e31076e4cc394bb64fdd9e3d8cb43b1 100644 (file)
@@ -56,6 +56,7 @@ typedef struct settings_st {
     uint32_t evt_mask;
     uint32_t cpu_mask;
     unsigned long tbuf_size;
+    int discard:1;
 } settings_t;
 
 settings_t opts;
@@ -307,6 +308,13 @@ int monitor_tbufs(FILE *logfile)
     meta  = init_bufs_ptrs(tbufs_mapped, num, size);
     data  = init_rec_ptrs(meta, num);
 
+    if(opts.discard) {
+        for ( i = 0; (i < num) ; i++ )
+        {
+           meta[i]->cons = meta[i]->prod;
+        }
+    }
+
     /* now, scan buffers for events */
     while ( !interrupted )
     {
@@ -413,6 +421,12 @@ error_t cmd_parser(int key, char *arg, struct argp_state *state)
     }
     break;
 
+    case 'D': /* Discard traces currently in the buffer before beginning */
+    {
+        opts.discard=1;
+    }
+    break;
+
     case ARGP_KEY_ARG:
     {
         if ( state->arg_num == 0 )
@@ -458,6 +472,11 @@ const struct argp_option cmd_opts[] =
       "N.B. that the trace buffer cannot be resized.  If it has "
       "already been set this boot cycle, this argument will be ignored." },
 
+    { .name = "discard-buffers", .key='D', .arg=NULL,
+      .flags=OPTION_ARG_OPTIONAL,
+      .doc = "Discard all records currently in the trace buffers before "
+      " beginning." },
+
     {0}
 };